home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / AppleShare IP SDK / ASIP User Authentication Module / Client UAM SDK / Headers / afpDatastream.h next >
Encoding:
C/C++ Source or Header  |  1999-05-21  |  12.5 KB  |  355 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        afpDatastream.h
  3.  
  4.      Contains:    Public Header file for the AppleShare Client API (AFP Protocol)
  5.  
  6.      Version:    3.8
  7.   
  8.      Copyright:    © 1997-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11. #ifndef __AFPDATASTREAM__
  12. #define __AFPDATASTREAM__
  13.  
  14. #ifndef __CONDITIONALMACROS__
  15. #include <ConditionalMacros.h>
  16. #endif
  17.  
  18. #ifndef __MIXEDMODE__
  19. #include <MixedMode.h>
  20. #endif
  21.  
  22. #ifndef __DEVICES__
  23. #include <Devices.h>
  24. #endif
  25.  
  26. #ifndef __APPLETALK__
  27. #include <AppleTalk.h>
  28. #endif
  29.  
  30. #ifndef __OPENTRANSPORT__
  31. #include <OpenTransport.h>
  32. #endif
  33.  
  34. #ifndef __OPENTPTINTERNET__
  35. #include <OpenTptInternet.h>
  36. #endif
  37.  
  38. #ifndef __OPENTPTAPPLETALK__
  39. #include <OpenTptAppleTalk.h>
  40. #endif
  41.  
  42.  
  43.  
  44.  
  45. #if PRAGMA_ONCE
  46. #pragma once
  47. #endif
  48.  
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52.  
  53. #if PRAGMA_IMPORT
  54. #pragma import on
  55. #endif
  56.  
  57. #if PRAGMA_STRUCT_ALIGN
  58.     #pragma options align=mac68k
  59. #elif PRAGMA_STRUCT_PACKPUSH
  60.     #pragma pack(push, 2)
  61. #elif PRAGMA_STRUCT_PACK
  62.     #pragma pack(2)
  63. #endif
  64.  
  65.  
  66.  
  67. /*    -------------------------------------------------------------------------
  68.     csCodes
  69.     ------------------------------------------------------------------------- */
  70. /* for PBControl calls*/
  71. enum {
  72.     afpGetAttnRoutine            = 252,                            /*    Get the default AFP Attention routine*/
  73.     dsOpenSession                = 244,                            /*    Open an AFP session to the server*/
  74.     dsGetStatus                    = 243,                            /*    Send a GetSrvrInfo request to the server*/
  75.     dsSendRequest                = 240,                            /*    Send an AFP command to the server*/
  76.     dsCloseSession                = 237,                            /*    Close the specified session*/
  77.     dsCloseAll                    = 232,                            /*    Close all sessions*/
  78.     dsIOCTL                        = 231,                            /*    Make an IOCTL call to the session endpoint iff it is TCP/IP*/
  79.                                                                 /* these will be retired soon    */
  80.     AFPInsSessMemBlk            = 246,                            /* insert the SMB into the drviers Queue    */
  81.     AFPRemSessMemBlk            = 245                            /* remove the SMB from the drviers Queue    */
  82. };
  83.  
  84. /* for PBStatus calls*/
  85. enum {
  86.     afpGetFSID                    = 127,                            /*    returns the File System ID    */
  87.     afpSVolInfo                    = 124,                            /*     returns basic info about the server volume (address, servername, username...)*/
  88.     afpXGetVolInfo                = 121,                            /*    returns extended info about the volume (server time offset, volume grade...)*/
  89.     afpGetSMBSize                = 118,                            /*  returns the size of the session memory block required for a new session*/
  90.     dsGetXPortInfo                = 236                            /*    returns information about the transport used for the given session*/
  91. };
  92.  
  93. /*    -------------------------------------------------------------------------
  94.     Data Stream Parameter Block
  95.     ------------------------------------------------------------------------- */
  96. typedef CALLBACK_API( void , DSIOCompletionProcPtr )(void *pb);
  97. /*
  98.     WARNING: DSIOCompletionProcPtr uses register based parameters under classic 68k
  99.              and cannot be written in a high-level language without 
  100.              the help of mixed mode or assembly glue.
  101. */
  102. typedef REGISTER_UPP_TYPE(DSIOCompletionProcPtr)                 DSIOCompletionUPP;
  103.  
  104.  
  105. /* csCode = dsSendRequest*/
  106.  
  107. struct DSWritePB {
  108.     UInt32                             dsWriteDataOffset;            /* <- specifies the write offset in the data*/
  109.     UInt32                             dsWriteBufferSize;            /* <- size of the data to be written*/
  110.     Byte *                            dsWriteBuffer;                /* <- ptr to data to be written*/
  111. };
  112. typedef struct DSWritePB                DSWritePB;
  113. /* csCode = dsGetStatus*/
  114.  
  115. struct DSGetStatusPB {
  116.     OTAddress *                        dsGSSrvrAddress;            /* <- OT Address of server to GetStatus() from (you also need to fill in the reply buffer & size)*/
  117.     const char *                    dsGSEpString;                /* <- endpoint string for the connection (nil == default)        */
  118. };
  119. typedef struct DSGetStatusPB            DSGetStatusPB;
  120. /* csCode = dsOpenSession*/
  121.  
  122. struct DSOpenPB {
  123.     AttnRoutineUPP                     dsOSAttnRoutine;            /* <- Custom attention routine (nil == default)*/
  124.     OTAddress *                        dsOSSrvrAddress;            /* <- OT Address of server to open a session to*/
  125.     Ptr                             dsOSSessionBlock;            /* <- ptr to the SMB; memory reserved for the session.*/
  126.     const char *                    dsOSEpString;                /* <- endpoint string for the connection (nil == default)        */
  127. };
  128. typedef struct DSOpenPB                    DSOpenPB;
  129. enum {
  130.     SMBSize                        = 2560                            /* size of the session memory block*/
  131. };
  132.  
  133.  
  134.  
  135. struct DSParamBlock {
  136.     QElem *                            qLink;                        /* - standard header stuff*/
  137.     short                             qType;                        /* - standard header stuff*/
  138.     short                             ioTrap;                        /* - standard header stuff*/
  139.     Ptr                             ioCmdAddr;                    /* - standard header stuff*/
  140.     DSIOCompletionUPP                 ioCompletion;                /* <- completion rtn point*/
  141.     OSErr                             ioResult;                    /* -> result from Async call*/
  142.     long                             cmdResult;                    /* -> result from the Server for the AFP Cmd*/
  143.     short                             ioVRefNum;                    /* - standard header stuff */
  144.     short                             ioCRefNum;                    /* <- RefNum of the ".AFPTranslator"*/
  145.     short                             csCode;                        /* <- DS Command code*/
  146.     short                             dsTimeout;                    /* <- ASP - How long to wait before retrying request, TCP - resv for internal use*/
  147.     short                             dsReserved1;                /* -  resv for internal use*/
  148.     long                             dsRetry;                    /* <- ASP - How many times to retry the request, TCP - unused*/
  149.     UInt16                             dsReserved2;                /* -  resv for internal use*/
  150.     short                             dsSessRefNum;                /* <- AFP Session number*/
  151.     short                             dsReserved3;                /* -  resv for internal use*/
  152.     short                             dsCmdBufferSize;            /* <- size of the command buffer*/
  153.     UInt8 *                            dsCmdBuffer;                /* <- ptr to the command buffer*/
  154.     UInt32                             dsReplyBufferSize;            /* <- size of the reply buffer*/
  155.     UInt8 *                            dsReplyBuffer;                /* <- ptr to the reply buffer*/
  156.  
  157.     union {
  158.         DSOpenPB                         open;
  159.         DSWritePB                         write;
  160.         DSGetStatusPB                     status;
  161.     }                                 csParam;
  162. };
  163. typedef struct DSParamBlock                DSParamBlock;
  164. typedef DSParamBlock *                    DSParamBlockPtr;
  165.  
  166. /* NOTE:
  167.     The dsCmdBuffer for the csCode = dsOpenSession case Must contain an AFP Login command.
  168.     The dsCmdBuffer for the csCode = dsCloseSession case Must contain an AFP Logout command.
  169.     Consult Inside AppleTalk for the packet formats.
  170. */
  171.  
  172.  
  173. struct DSXPortInfo {
  174.     long                             dsXPortType;                /* Transport Type (kASPXport, kTCPXport)*/
  175.     short                             dsXPortSessRefNum;            /* Session ref number for ASP or TCP*/
  176.     union {
  177.         InetAddress                     ipAddr;
  178.         DDPAddress                         ddpAddr;
  179.     }                                 addr;
  180. };
  181. typedef struct DSXPortInfo                DSXPortInfo;
  182. typedef DSXPortInfo *                    DSXPortInfoPtr;
  183. /* definitions for     dsXPortType */
  184. enum {
  185.     kASPXport                    = 0x00,
  186.     kTCPXport                    = 0x01
  187. };
  188.  
  189. /* argument structure for the dsIOCTL call, put a pointer to the DSIOCTLArgs 
  190.    struct into the dsCmdBuffer field & fill out the dsCmdBufferSize with
  191.    sizeof(DSIOCTLArgs). put the session refnum of the session
  192.    you are interested in, into dsSessRefNum. The result of the IOCTL
  193.    call will be in the cmdResult field. if the session is not a TCP/IP
  194.    session you will recieve an error <??? Which one> ENOTSOCK?
  195. */
  196.  
  197. struct DSIOCTLArgs {
  198.     UInt32                             ioctlCmd;
  199.     void *                            ioctlData;
  200. };
  201. typedef struct DSIOCTLArgs                DSIOCTLArgs;
  202. typedef DSIOCTLArgs *                    DSIOCTLArgsPtr;
  203.  
  204.  
  205.  
  206.  
  207. struct GetVolSessInfoRec {
  208.     short                             sessAFPVersion;                /*    AFP version number: */
  209.     short                             sessReferenceNumber;        /*    AFP session reference number*/
  210.     short                             sessAFPVolID;                /*    AFP volume identifier*/
  211.     OTAddress *                        sessServerAddress;            /*    server internet address*/
  212.     short                             sessUAMType;                /*    user authentication method*/
  213.     StringPtr                         sessUserNamePtr;            /*    ptr to user name string*/
  214.     Ptr                             sessVolIconPtr;                /*    ptr to server volume icon/mask*/
  215.     StringPtr                         sessWhereStringPtr;            /*    ptr to "where" information string, shown in the Get Info window*/
  216. };
  217. typedef struct GetVolSessInfoRec        GetVolSessInfoRec;
  218. typedef GetVolSessInfoRec *                GetVolSessInfoRecPtr;
  219. enum {
  220.     kAFPVersion11                = 1,
  221.     kAFPVersion20                = 2,
  222.     kAFPVersion21                = 3,
  223.     kAFPVersion22                = 4
  224. };
  225.  
  226. enum {
  227.     kNoUserAuth                    = 1,                            /*    'No User Authent' UAM (Guest)*/
  228.     kCleartextAuth                = 2,                            /*    'Cleartxt Passwrd' UAM     (types 2 & 3 will be automatically upgraded to 6 if avail.)*/
  229.     kRandnumAuth                = 3,                            /*    'Randnum Exchange' UAM */
  230.     k2WayRandnumAuth            = 6,                            /*    '2-Way Randnum exchange'*/
  231.     kEncryptPassXport            = 7,                            /*  'DHXCAST128' UAM (Diffie Hellman password transport)*/
  232.     kMinCustomUAM                = 128                            /*    Minimum type value for a Custom UAM*/
  233. };
  234.  
  235.  
  236. struct GetVolSessInfoPB {
  237.     QElemPtr                         qLink;                        /*  -  standard header stuff*/
  238.     short                             qType;                        /*  -  standard header stuff*/
  239.     short                             ioTrap;                        /*  -  standard header stuff*/
  240.     Ptr                             ioCmdAddr;                    /*  -  standard header stuff*/
  241.     IOCompletionUPP                 ioCompletion;                /* <-  completion rtn pointer*/
  242.     OSErr                             ioResult;                    /*  -> result from Async call*/
  243.     StringPtr                         ioNamePtr;                    /*  -  standard header stuff*/
  244.     short                             ioVRefNum;                    /*  -  standard header stuff*/
  245.     short                             ioRefNum;                    /* <-  RefNum of the ".AFPTranslator"*/
  246.     short                             csCode;                        /* <-  allways afpSVolInfo*/
  247.     Ptr                             vcbPtr;                        /* <-  pointer to the VCB that you want info about*/
  248.     GetVolSessInfoRecPtr             sessInfoBuffer;                /* <-  pointer to the GetVolSessInfoRec to be filled*/
  249.     long                             sessInfoSize;                /* <-  size of the GetVolSessInfoRec*/
  250.     long                             actSessInfoSize;            /*  -> actual size of the data returned*/
  251. };
  252. typedef struct GetVolSessInfoPB            GetVolSessInfoPB;
  253. typedef GetVolSessInfoPB *                GetVolSessInfoPBPtr;
  254. /* the AFPInsSessMemBlk & AFPRemSessMemBlk  calls are currently  required
  255.    when opening or closing a session. Make the AFPInsSessMemBlk call after the dsOpenSession
  256.    call succeeds (or returns afpAuthContinue), with the same dsOSSessionBlock that you
  257.    sent into dsOpenSession. You need to call AFPRemSessMemBlk with that same pointer after
  258.    calling dsCloseSession or dsCloseAll. 
  259. */
  260.  
  261. struct AFPInsRemSMBParam {
  262.     QElemPtr                         qLink;                        /*  -  standard header stuff    */
  263.     short                             qType;                        /*  -  standard header stuff    */
  264.     short                             ioTrap;                        /*  -  standard header stuff    */
  265.     Ptr                             ioCmdAddr;                    /*  -  standard header stuff    */
  266.     IOCompletionUPP                 ioCompletion;                /* <-  completion rtn pointer    */
  267.     OSErr                             ioResult;                    /*  -> result from Async call    */
  268.     StringPtr                         ioNamePtr;                    /*  -  standard header stuff    */
  269.     short                             ioVRefNum;                    /*  -  standard header stuff    */
  270.     short                             ioRefNum;                    /* <-  RefNum of the ".AFPTranslator"            */
  271.     short                             csCode;                        /* <-  AFPInsSessMemBlk or AFPRemSessMemBlk     */
  272.     Ptr                             smbPtr;                        /* <-> pointer to the SMB to insert or remove    */
  273. };
  274. typedef struct AFPInsRemSMBParam        AFPInsRemSMBParam;
  275.  
  276. typedef AFPInsRemSMBParam *                AFPInsRemSMBPBPtr;
  277. /* Server Info Buffer returned from the dsGetStatus call     */
  278. /* you should make your buffer at least 1024 bytes in size.    */
  279. /* a partial definition of the AFPSrvrInfo data structure (the fixed portion) */
  280.  
  281. struct AFPSrvrInfo {
  282.     short                             fMachineOffset;
  283.     short                             fVerCountOffset;
  284.     short                             fUAMCountOffset;
  285.     short                             fIconOffset;
  286.     short                             fFlags;
  287.     unsigned char                     fSrvrName[2];
  288. };
  289. typedef struct AFPSrvrInfo                AFPSrvrInfo;
  290. /* definitions for the fFlags word    */
  291. enum {
  292.     srvSCopyFile                = 0,                            /* Server supports FPCopyFile call*/
  293.     srvSChangePswd                = 1,                            /* Server supports FPChangePassword call*/
  294.     srvNoPswdSave                = 2,                            /* Workstation should not save password*/
  295.     srvSServerMsgs                = 3,                            /* Server supports server messages*/
  296.     srvSSrvrSig                    = 4,                            /* Server supports Server Signatures  (AFP 2.2)*/
  297.     srvSupportsTCP                = 5,                            /* Server may be connected to via TCP/IP (AFP 2.2)*/
  298.     srvSNotification            = 6                                /* Server will send notifications (AFP 2.2)*/
  299. };
  300.  
  301.  
  302. /* Gestalt selectors & definitions    (additions to the ones in gestalt.h) */
  303. enum {
  304.     gestaltAFPClient3_8            = 8,
  305.     gestaltAFPClient3_8_1        = 9
  306. };
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  314.                                                                                             #pragma parameter __D0 NAFPCommandSync(__A0)
  315.                                                                                             #endif
  316. EXTERN_API( OSErr ) NAFPCommandSync(DSParamBlockPtr paramBlock)                                ONEWORDINLINE(0xA004);
  317.  
  318.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  319.                                                                                             #pragma parameter __D0 NAFPCommandAsync(__A0)
  320.                                                                                             #endif
  321. EXTERN_API( OSErr ) NAFPCommandAsync(DSParamBlockPtr paramBlock)                            ONEWORDINLINE(0xA404);
  322.  
  323.  
  324. /* use only for dsCloseAll    */
  325.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  326.                                                                                             #pragma parameter __D0 NAFPCommandImmediate(__A0)
  327.                                                                                             #endif
  328. EXTERN_API( OSErr ) NAFPCommandImmediate(DSParamBlockPtr paramBlock)                        ONEWORDINLINE(0xA204);
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335. #if PRAGMA_STRUCT_ALIGN
  336.     #pragma options align=reset
  337. #elif PRAGMA_STRUCT_PACKPUSH
  338.     #pragma pack(pop)
  339. #elif PRAGMA_STRUCT_PACK
  340.     #pragma pack()
  341. #endif
  342.  
  343. #ifdef PRAGMA_IMPORT_OFF
  344. #pragma import off
  345. #elif PRAGMA_IMPORT
  346. #pragma import reset
  347. #endif
  348.  
  349. #ifdef __cplusplus
  350. }
  351. #endif
  352.  
  353. #endif /* __APPLESHARE__ */
  354.  
  355.